{include file='public/head' /}
<style type="text/css">
  .badge{
    width:25px;
    height:25px;
    border-radius: 5px;
    line-height: 20px;
    text-align: center;
    font-size: 12px;
  }
  .tablelist tr {
    border:1px solid #CFCFCF;
  }
  .tablelist tr td,.tablelist tr th{
    border:1px solid #CFCFCF;
  }
</style>
    <div class="col-sm-9 col-sm-offset-3 col-md-10 col-lg-10 col-md-offset-2 main" id="main" style="padding:10px;">
        <h1 class="page-header">开奖记录
        <!--   <button type="button" class="btn btn-danger"  title="删除全部选中" id="deleteSelect">删除</button> -->
        </h1>
        <div class="table-responsive" style="margin-top: -20px;">
           <form action="{:url('admin/result/index')}" method="get" class="navbar-form navbar-right" role="search" style="margin-top: 5px;">
            <div class="input-group">
              <input type="text" class="form-control" autocomplete="off" placeholder="键入关键字搜索" value='{$Think.get.key}' name="key" style="width:190px">
            <span class="input-group">
             <input class="btn btn-primary" type="submit" value="搜索" style="border-radius: 0 3px 3px 0">&nbsp;
             <button class="btn btn-primary" name="all" value="1">显示全部</button>
              </span>  </div>
           </form>
          <table class="table table-striped table-hover tablelist">
            <thead>
              <tr style="background-color: #3399CC;color: white">
                <th><input type="checkbox" id="all" style="position: relative;top:2px"/><span class="glyphicon glyphicon-th-large"></span> <span>选择</span></th>
                <th><span class="glyphicon glyphicon-file"></span> <span>开奖期数</span></th>
                <th><span class="glyphicon glyphicon-list"></span> <span>号码</span></th>
                <th><span class="glyphicon glyphicon-time"></span> <span>日期</span></th>
                <th><span class="glyphicon glyphicon-pencil"></span> <span>操作</span></th>
              </tr>
            </thead>
            <tbody>
              <tr><td colspan="5">
              下一期 : <span style="color:red">{$next.qishu}</span>
              <span style="color: red"> | </span>  
              买涨 : <span style="color:red">{$next.up}</span> 人</span>
              <span style="color: red"> | </span>   
              买涨总金额 : <span style="color:red;font-size:40px;">{$next.ups}</span> 元</span>
              <span style="color: red"> | </span> 
              买跌 : <span style="color:red">{$next.down}</span> 人</span>
              <span style="color: red"> | </span> 
              买跌总金额 : <span style="color:red;font-size:40px;">{$next.downs}</span> 元</span>
              <span style="color: red"> | </span> 
              对称相差 : <span style="color:#000;font-size:40px;">
                {if condition="$next.ups-$next.downs gt $next.downs"}
                  涨{$next.ups-$next.downs}
                {else/}
                  跌{$next.downs-$next.ups}
                {/if}
              </span>
              <span style="color: red"> | </span> 
              利润 : 
               {if condition="$next.ups gt $next.downs"}
                <span style="color:red">{$next.downs*(2-$next.allodds)}
                </span>  
                {else/}
                <span style="color:red">{$next.ups*(2-$next.allodds)}
                </span>  
               {/if}
              </td></tr>
              {volist name="data" id="vo"}
              <tr>
                <td><input type="checkbox" class="input-control" value="{$vo.id}"/>{$vo.id}</td>
                <td>{$vo.qishu}</td>
                <td>
                  {empty name="$vo.ball1"}
                  {else/}
                  {switch $vo.ball1}
                      {case 1}<span class="badge" style="background-color:#FEFA0A;">{/case}
                      {case 2}<span class="badge" style="background-color:#008DFF;">{/case}
                      {case 3}<span class="badge" style="background-color:#4D4A4D;">{/case}
                      {case 4}<span class="badge" style="background-color:#FE7700;">{/case}
                      {case 5}<span class="badge" style="background-color:#8CFBFD;">{/case}
                      {case 6}<span class="badge" style="background-color:#3E0DED;">{/case}
                      {case 7}<span class="badge" style="background-color:#E2E5E2;">{/case}
                      {case 8}<span class="badge" style="background-color:#FA0700;">{/case}
                      {case 9}<span class="badge" style="background-color:#750002;">{/case}
                      {default/}<span class="badge" style="background-color:#21CE06;">
                  {/switch}
                  {$vo.ball1}</span>
                  {switch $vo.ball2}
                      {case 1}<span class="badge" style="background-color:#FEFA0A;">{/case}
                      {case 2}<span class="badge" style="background-color:#008DFF;">{/case}
                      {case 3}<span class="badge" style="background-color:#4D4A4D;">{/case}
                      {case 4}<span class="badge" style="background-color:#FE7700;">{/case}
                      {case 5}<span class="badge" style="background-color:#8CFBFD;">{/case}
                      {case 6}<span class="badge" style="background-color:#3E0DED;">{/case}
                      {case 7}<span class="badge" style="background-color:#E2E5E2;">{/case}
                      {case 8}<span class="badge" style="background-color:#FA0700;">{/case}
                      {case 9}<span class="badge" style="background-color:#750002;">{/case}
                      {default/}<span class="badge" style="background-color:#21CE06;">
                  {/switch}
                  {$vo.ball2}</span>
                  {switch $vo.ball3}
                      {case 1}<span class="badge" style="background-color:#FEFA0A;">{/case}
                      {case 2}<span class="badge" style="background-color:#008DFF;">{/case}
                      {case 3}<span class="badge" style="background-color:#4D4A4D;">{/case}
                      {case 4}<span class="badge" style="background-color:#FE7700;">{/case}
                      {case 5}<span class="badge" style="background-color:#8CFBFD;">{/case}
                      {case 6}<span class="badge" style="background-color:#3E0DED;">{/case}
                      {case 7}<span class="badge" style="background-color:#E2E5E2;">{/case}
                      {case 8}<span class="badge" style="background-color:#FA0700;">{/case}
                      {case 9}<span class="badge" style="background-color:#750002;">{/case}
                      {default/}<span class="badge" style="background-color:#21CE06;">
                  {/switch}
                  {$vo.ball3}</span>
                  {switch $vo.ball4}
                      {case 1}<span class="badge" style="background-color:#FEFA0A;">{/case}
                      {case 2}<span class="badge" style="background-color:#008DFF;">{/case}
                      {case 3}<span class="badge" style="background-color:#4D4A4D;">{/case}
                      {case 4}<span class="badge" style="background-color:#FE7700;">{/case}
                      {case 5}<span class="badge" style="background-color:#8CFBFD;">{/case}
                      {case 6}<span class="badge" style="background-color:#3E0DED;">{/case}
                      {case 7}<span class="badge" style="background-color:#E2E5E2;">{/case}
                      {case 8}<span class="badge" style="background-color:#FA0700;">{/case}
                      {case 9}<span class="badge" style="background-color:#750002;">{/case}
                      {default/}<span class="badge" style="background-color:#21CE06;">
                  {/switch}
                  {$vo.ball4}</span>
                  {switch $vo.ball5}
                      {case 1}<span class="badge" style="background-color:#FEFA0A;">{/case}
                      {case 2}<span class="badge" style="background-color:#008DFF;">{/case}
                      {case 3}<span class="badge" style="background-color:#4D4A4D;">{/case}
                      {case 4}<span class="badge" style="background-color:#FE7700;">{/case}
                      {case 5}<span class="badge" style="background-color:#8CFBFD;">{/case}
                      {case 6}<span class="badge" style="background-color:#3E0DED;">{/case}
                      {case 7}<span class="badge" style="background-color:#E2E5E2;">{/case}
                      {case 8}<span class="badge" style="background-color:#FA0700;">{/case}
                      {case 9}<span class="badge" style="background-color:#750002;">{/case}
                      {default/}<span class="badge" style="background-color:#21CE06;">
                  {/switch}
                  {$vo.ball5}</span>
                  {switch $vo.ball6}
                      {case 1}<span class="badge" style="background-color:#FEFA0A;">{/case}
                      {case 2}<span class="badge" style="background-color:#008DFF;">{/case}
                      {case 3}<span class="badge" style="background-color:#4D4A4D;">{/case}
                      {case 4}<span class="badge" style="background-color:#FE7700;">{/case}
                      {case 5}<span class="badge" style="background-color:#8CFBFD;">{/case}
                      {case 6}<span class="badge" style="background-color:#3E0DED;">{/case}
                      {case 7}<span class="badge" style="background-color:#E2E5E2;">{/case}
                      {case 8}<span class="badge" style="background-color:#FA0700;">{/case}
                      {case 9}<span class="badge" style="background-color:#750002;">{/case}
                      {default/}<span class="badge" style="background-color:#21CE06;">
                  {/switch}
                  {$vo.ball6}</span>
                  {switch $vo.ball7}
                      {case 1}<span class="badge" style="background-color:#FEFA0A;">{/case}
                      {case 2}<span class="badge" style="background-color:#008DFF;">{/case}
                      {case 3}<span class="badge" style="background-color:#4D4A4D;">{/case}
                      {case 4}<span class="badge" style="background-color:#FE7700;">{/case}
                      {case 5}<span class="badge" style="background-color:#8CFBFD;">{/case}
                      {case 6}<span class="badge" style="background-color:#3E0DED;">{/case}
                      {case 7}<span class="badge" style="background-color:#E2E5E2;">{/case}
                      {case 8}<span class="badge" style="background-color:#FA0700;">{/case}
                      {case 9}<span class="badge" style="background-color:#750002;">{/case}
                      {default/}<span class="badge" style="background-color:#21CE06;">
                  {/switch}
                  {$vo.ball7}</span>
                  {switch $vo.ball8}
                      {case 1}<span class="badge" style="background-color:#FEFA0A;">{/case}
                      {case 2}<span class="badge" style="background-color:#008DFF;">{/case}
                      {case 3}<span class="badge" style="background-color:#4D4A4D;">{/case}
                      {case 4}<span class="badge" style="background-color:#FE7700;">{/case}
                      {case 5}<span class="badge" style="background-color:#8CFBFD;">{/case}
                      {case 6}<span class="badge" style="background-color:#3E0DED;">{/case}
                      {case 7}<span class="badge" style="background-color:#E2E5E2;">{/case}
                      {case 8}<span class="badge" style="background-color:#FA0700;">{/case}
                      {case 9}<span class="badge" style="background-color:#750002;">{/case}
                      {default/}<span class="badge" style="background-color:#21CE06;">
                  {/switch}
                  {$vo.ball8}</span>
                  {switch $vo.ball9}
                      {case 1}<span class="badge" style="background-color:#FEFA0A;">{/case}
                      {case 2}<span class="badge" style="background-color:#008DFF;">{/case}
                      {case 3}<span class="badge" style="background-color:#4D4A4D;">{/case}
                      {case 4}<span class="badge" style="background-color:#FE7700;">{/case}
                      {case 5}<span class="badge" style="background-color:#8CFBFD;">{/case}
                      {case 6}<span class="badge" style="background-color:#3E0DED;">{/case}
                      {case 7}<span class="badge" style="background-color:#E2E5E2;">{/case}
                      {case 8}<span class="badge" style="background-color:#FA0700;">{/case}
                      {case 9}<span class="badge" style="background-color:#750002;">{/case}
                      {default/}<span class="badge" style="background-color:#21CE06;">
                  {/switch}
                  {$vo.ball9}</span>
                  {switch $vo.ball10}
                      {case 1}<span class="badge" style="background-color:#FEFA0A;">{/case}
                      {case 2}<span class="badge" style="background-color:#008DFF;">{/case}
                      {case 3}<span class="badge" style="background-color:#4D4A4D;">{/case}
                      {case 4}<span class="badge" style="background-color:#FE7700;">{/case}
                      {case 5}<span class="badge" style="background-color:#8CFBFD;">{/case}
                      {case 6}<span class="badge" style="background-color:#3E0DED;">{/case}
                      {case 7}<span class="badge" style="background-color:#E2E5E2;">{/case}
                      {case 8}<span class="badge" style="background-color:#FA0700;">{/case}
                      {case 9}<span class="badge" style="background-color:#750002;">{/case}
                      {default/}<span class="badge" style="background-color:#21CE06;">
                  {/switch}
                  {$vo.ball9}</span>
                  {/empty}
                </td>
                <td>{$vo.time}</td>
                <td>
                  <a rel="1" href="{:url('see',['qishu'=>$vo['qishu'],'status'=>$vo['status']])}" class="btn btn-primary btn-xs" name="see">查看订单明细</a>
                 <a class="btn btn-danger btn-xs" href="{:url('kai',['qishu'=>$vo['qishu'],'status'=>$vo['status']])}">开奖</a>
                 
                 <a class="btn btn-danger btn-xs" href="{:url('del',['id'=>$vo['id'],'status'=>$vo['status']])}">删除</a>
                 </td>

              </tr>  
              {/volist}
            </tbody>
          </table>
        </div>
        <footer class="message_footer" style="margin-top: -10px;">
        {if condition="$all eq 1"}
        {else/}
        <span style="float: left;margin-top: 15px;">第{$data->currentPage()} 页 / 共 {$data->lastPage()} 页 ( 总 共 {$data->total()} 条 记 录 )</span> 
        <div style="float: right;margin-top: -10px;">  
        <div class="page" style="margin-top: 5px;">
        {$data->render()}
        </div>
        </div>
        {/if}
        </footer>
    </div>
  </div>
</section>
<script>
  //单条记录删除
  $('.del').click(function(){
      var del = confirm("你确定要删除吗？");
       if(del == false){
        return false;
      }  
  });
  //多选删除
  $('#deleteSelect').click(function(){
    //获取【被选择】的行的id
      var trObj = $(".tablelist tbody tr");
      var ids = new Array();
      var mainObjs = new Array();
      //遍历每一行
      for($i=0;$i<trObj.length;$i++){
         if(trObj.eq($i).find("input").attr('checked')){
            //组装ids数组
            ids[ids.length]=trObj.eq($i).find("input").val();
            //组装mainObj数组
            mainObjs[mainObjs.length]=trObj.eq($i);
         }
      }   
    if(ids.length>0){
        //启动ajax
        $.ajax({
            url:"{:url('deleteall')}",
            type:'post',
            data:{'id':ids},
            async:false, 
            dataType:'json',
            success:function (d) {
                console.log(d);
            if(d==1) {
                var a = confirm("你确定要删除吗？");
                if(a == true){
                   //将前端被选择的多选框所在的行移除DOM
                    for($i=0;$i<mainObjs.length;$i++){
                        mainObjs[$i].fadeOut(500,function(){
                            $(this).remove();
                            history.go(0);
                        });
                    }
                }else{
                   history.go(0);
                }
              } else if (d == 2) {
                     //删除失败
                   alert('删除失败');
               }

            }

        });
    }else{
       alert("你没有选择要删除的内容，请选择后再【批量删除】");
    }  
 
  });
  //全选或全不选
  $("#all").click(function(){ 
      if(this.checked){
         $(".tablelist tbody tr :checkbox").attr("checked", true);
        
      }else{
         $(".tablelist tbody tr :checkbox").removeAttr("checked", false);
      }
  });

function f(){
  window.location.href = "{:url('admin/result/index')}";
}

window.setInterval(f, 10000);

</script>
</body>
</html>
